<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="template.xhtml">
	<ui:define name="content">
	
	<h1>Risultati della ricerca:</h1>
	
	<h:form>
	<p:panelGrid columns="7">
		
		<h:outputLabel value="Seleziona la tua meta:" />
	   	<p:selectOneMenu value="#{packageSearchBean.searchParameters.locationId}" 
	                     effect="fade" filter="true" filterMatchMode="contains">  
	        <f:selectItem itemLabel="Qualsiasi destinazione" itemValue="0" />  
	        <f:selectItems value="#{packageSearchBean.allLocations}" var="loc" itemLabel="#{loc.name} (#{loc.nation.name})" itemValue="#{loc.id}"/>  
	
	    </p:selectOneMenu>
	    
	    <h:outputLabel value="Partenza:" />
	    <p:calendar value="#{packageSearchBean.searchParameters.fromDate}" mindate="#{packageSearchBean.today}" editable="false" />
	    
		<p:commandButton value="Pulisci" action="#{packageSearchBean.resetFields}"></p:commandButton>
		<p:commandButton value="Ricerca" action="#{packageSearchBean.searchPackage}"></p:commandButton>
	</p:panelGrid>
	</h:form>
	<br />
	<p:dataTable var="package" value="#{packageSearchBean.results}" emptyMessage="Spiacenti, nessun elemento corrisponde ai criteri di ricerca.">  
        <p:column headerText="">  
            <p:graphicImage style="width: 200px;" value="../images/packages/#{package.id}.jpg" />  
        </p:column>  
  
        <p:column headerText="Pacchetto">  
            <h:outputText value="#{package.name}" />  
        </p:column>  
  
        <p:column headerText="Descrizione">  
            <h:outputText value="#{package.description}" />  
        </p:column>  
  
  		<p:column headerText="Periodo">  
            <h:outputText value="#{package.period.name}" /> <br />Tra il   
            <h:outputText value="#{package.period.fromDate}">
            	<f:convertDateTime pattern="dd.MM.yyyy" />
            </h:outputText> e il 
            <h:outputText value="#{package.period.toDate}">
            	<f:convertDateTime pattern="dd.MM.yyyy" />
            </h:outputText>
        </p:column>
  
  		<p:column headerText="Prezzo">  
            <h:outputText value="#{package.extra}" />  
        </p:column>
  
        <p:column headerText="Visualizza">  
            <center><p:button outcome="packageDetails" icon="ui-icon-search" title="Visualizza dettagli">  
			    <f:param name="packageId" value="#{package.id}" />  
			</p:button></center>
        </p:column>  
    </p:dataTable>
	
	
	</ui:define>
</ui:composition>
</html>